﻿/**************************************************************************
创建时间:	2020/11/15
作	  者:	张存
邮 	  箱:	zhangcunliang@126.com

Copyright (c) zhcun.cn

描	述：
记	录：
***************************************************************************/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ASmile.Win.Controls
{
    public class LabelEx : Label
    {
        public LabelEx()
        {
            TextAlign = ContentAlignment.MiddleRight;
            AutoSize = false;
        }

        [DefaultValue(false)]
        public override bool AutoSize { get ; set ; }

        //[Browsable(true)]
        //[Localizable(true)]
        //[AmbientValue(null)]
        //[SRCategoryAttribute("CatLayout")]
        //[SRDescriptionAttribute("ControlLocationDescr")]
        public CustomBorderStyle CustomBorder { get; } = new CustomBorderStyle();

        public bool CustomBorderUse { set; get; } = false;

        protected override void OnPaint(PaintEventArgs e)
        {
           // this.Location

           base.OnPaint(e);

            DrawBorder(e.Graphics);
        }

        private void DrawBorder(Graphics g)
        {
            if (!CustomBorderUse) return;

            ControlPaint.DrawBorder(g, ClientRectangle,
                CustomBorder.LeftColor, CustomBorder.LeftWidth, ButtonBorderStyle.Solid,    //左
                CustomBorder.TopColor, CustomBorder.TopWidth, ButtonBorderStyle.Solid,    //上 
                CustomBorder.RightColor, CustomBorder.RightWidth, ButtonBorderStyle.Solid,    //右
                CustomBorder.BottomColor, CustomBorder.BottomWidth, ButtonBorderStyle.Solid);
        }
    }
}
